using Game.UIScripts;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Game
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        public const int GridSize = 32;
        //private int _viewportWidth, _viewportHeight;

        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        //private Level _level;
        private UIController _ui;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.IsFullScreen = true;
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _ui = new UIController(Services, GraphicsDevice,this);
            
            base.Initialize();
        }

        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
        }

        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }



        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            /*if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))//ESCAPE TO EXIT
                this.Exit();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                Exit();*/

            // TODO: Add your update logic here
            //_level.Update(gameTime, Keyboard.GetState(), Mouse.GetState());
            _ui.Update(gameTime, Keyboard.GetState(), Mouse.GetState());

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);

            // TODO: Add your drawing code here
            //_level.Draw(gameTime, spriteBatch);
            //_level.DebugDraw(spriteBatch, _viewportWidth, _viewportHeight);
            _ui.Draw(gameTime,spriteBatch);

            base.Draw(gameTime);
        }

        public void exitGame()
        {
            this.Exit();
        }
    }
}
